package com.cf.r1043_d;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class a {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
        int n = Integer.parseInt(br.readLine());
        StringBuilder a = new StringBuilder(br.readLine());
        int m = Integer.parseInt(br.readLine());
        char[] b = br.readLine().toCharArray();
        char[] c = br.readLine().toCharArray();
        for (int i = 0; i < m; i++) {
            if (c[i] == 'D') {
                a.append(b[i]);
            } else {
                a.insert(0, b[i]);
            }
        }
        out.println(a);
    }
}
